//
//  HWVipGiftBagOnPlayHeader.swift
//  HWanGame
//
//  Created by 王昌健 on 2021/12/10.
//  Copyright © 2021 94Wan. All rights reserved.
//

import UIKit

class HWVipGiftBagOnPlayHeader: UIView {
    var bgImageView:UIImageView!
    var receiveButton:UIButton!
    var gameImageView:UIImageView!
    var gameNameLabel:UILabel!
    
//    class func headerOrFooterWithTableView(tableView:UITableView) -> (HWVipGiftBagOnPlayHeader) {
//        let reUse:String = "HWVipGiftBagOnPlayHeader"
//
//        var headerOrFooter = tableView.dequeueReusableHeaderFooterView(withIdentifier: reUse)
//
//        if headerOrFooter == nil {
//            headerOrFooter = HWVipGiftBagOnPlayHeader.init(reuseIdentifier: reUse)
//        }
//
//        return headerOrFooter as! HWVipGiftBagOnPlayHeader
//    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
//    override init(reuseIdentifier: String?) {
//        super.init(reuseIdentifier: reuseIdentifier)
//        initUI()
//        initFrame()
//    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        initUI()
        initFrame()
    }
    
    func initUI() -> Void {
        
        backgroundColor = .white
        
        bgImageView = UIImageView()
        bgImageView.image = UIImage(named: "vipBagOnPlayHeader")
        addSubview(bgImageView)
        
        receiveButton = UIButton(type: .custom)
        receiveButton.setTitle("一键领取", for: .normal)
        receiveButton.titleLabel?.font = .boldSystemFont(ofSize: 12)
        receiveButton.setTitleColor(.colorWithHexString(hexString: "#4F3200"), for: .normal)
        receiveButton.setBackgroundImage(UIImage(named: "oneKeyReceiveBg"), for: .normal)
        bgImageView.addSubview(receiveButton)
        
        gameImageView = UIImageView()
        gameImageView.backgroundColor = .red
        gameImageView.layer.cornerRadius = 8
        gameImageView.layer.masksToBounds = true
        addSubview(gameImageView)
        
        gameNameLabel = HWLabel.createBoldLabel(title: "-", color: "#333333", font: 12)
        addSubview(gameNameLabel)
    }
    
    func initFrame() -> Void {
        bgImageView.snp.makeConstraints { make in
            make.left.top.equalToSuperview()
            make.right.equalTo(-13*widthScale)
            make.height.equalTo(bgImageView.snp.width).multipliedBy(0.11)
        }
        
        receiveButton.snp.makeConstraints { make in
            make.width.equalTo(76*widthScale)
            make.height.equalTo(27*widthScale)
            make.right.equalTo(-2*widthScale)
            make.centerY.equalToSuperview()
        }
        
        gameImageView.snp.makeConstraints { make in
            make.left.equalTo(15*widthScale)
            make.top.equalTo(bgImageView.snp.bottom).offset(9*widthScale)
            make.width.height.equalTo(40*widthScale)
        }
        
        gameNameLabel.snp.makeConstraints { make in
            make.left.equalTo(gameImageView.snp.right).offset(4*widthScale)
            make.centerY.equalTo(gameImageView)
        }
    }
}
